﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace QuanLyPhongKham
{
    /// <summary>
    /// Represent a controller for get values from web.config appSettings
    /// </summary>
    public class AppSettingController
    {
        /// <summary>
        /// Gets the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        public static T Get<T>(string key)
        {
            string str = ConfigurationManager.AppSettings[key];
            try
            {
                T newVal = (T)Convert.ChangeType(str, typeof(T));
                return newVal;
            }
            catch (Exception ex) {
                return default(T);
            }
        }
    }
}
